import { ref, onMounted, onBeforeMount, reactive } from 'vue';
// import { selectObject } from '@/utils/commonList';
import { commonList } from '@/api/common/common';
import type { CommonListItem } from '@/api/common/common.d';
import type { MarkItem, TableListItem } from '@/api/userManage/userManage.d';
import { getMarkData as FeatchMarkList } from '@/api/userManage/userManage';
import { getTableData as QueryList } from '@/api/userManage/userManage';
// import { Message } from '@arco-design/web-vue';

// 科室集合
const departmentList = ref<CommonListItem[]>([]);
// 任务状态集合
const statusList = ref<CommonListItem[]>([]);
// 任务用途集合
const taskUseList = ref<CommonListItem[]>([]);
// 标注单位集合
const sicknessList = ref<MarkItem[]>([]);
// 标注标签集合
const taskLabelList = ref<CommonListItem[]>([]);
// 标注目标集合
const taskTargetList = ref<CommonListItem[]>([]);
// 医生姓名集合
const doctorList = ref<TableListItem[]>([]);
// 影像转换模式
const imageTransferModeList = ref<any[]>([]);
export default function useGetSelect() {

    // 获取标注单位list
    const getMarkListData = async() => {
        const params = {
            // status: 1
        };
        const res = await FeatchMarkList(params);
        res && (sicknessList.value = res.data);
    };

    // 获取用户list
    const getUserListData = async () => {
        const params = {
            status: 1,
            page: 1,
            pageSize: 10000
        };
        const res = await QueryList(params);
        res && (doctorList.value = res.data.list);
    }

    const initSelectData = async () => {
        const res = await commonList();
        try {
            const { departments, taskUses, taskLabels, taskTargets, imageTransferModes,...newRes } = res?.data;
            // 科室处理
            departments && (departmentList.value = [...departments]);
            // 任务状态处理
            // newRes['任务状态'] && (statusList.value = [...newRes['任务状态']]);
            statusList.value = [
                {
                    name: '未发布',
                    value: '0'
                },
                {
                    name: '进行中',
                    value: '1'
                },
                {
                    name: '已完成',
                    value: '2'
                },
                {
                    name: '已终结',
                    value: '3'
                }
            ]
            // 任务用途处理
            taskUses && (taskUseList.value = [...taskUses]);
            // 标注单位处理
            // newRes['标注单位'] && (sicknessList.value = [...newRes['标注单位']]);
            getMarkListData();
            // 标注标签处理
            taskLabels && (taskLabelList.value = [...taskLabels]);
            // 标注目标处理
            taskTargets && (taskTargetList.value = [...taskTargets]);
            // 医生姓名处理
            // newRes['医生姓名'] && (doctorList.value = [...newRes['医生姓名']]);
            getUserListData();

            //影像转换模式
            imageTransferModes && (imageTransferModeList.value = [...imageTransferModes])
        } catch (error) {
            console.log(error, 'error');
            // Message.error('代码错误了');
        };
    };

    return {
        departmentList,
        statusList,
        taskUseList,
        sicknessList,
        taskLabelList,
        taskTargetList,
        doctorList,
        imageTransferModeList,
        initSelectData
    }
}